<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  <title>提现</title>
  <link rel="stylesheet" type="text/css" href="./css/api.css" />
  <link rel="stylesheet" type="text/css" href="./css/aui.css" />
  <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
  <link rel="stylesheet" type="text/css" href="./css/styleold.css" />
  <script type="text/javascript" src="./script/api.js"></script>
  <script type="text/javascript" src="./script/aui-tab.js" ></script>
  <link rel="stylesheet" type="text/css" href="./css/aui-slide.css" />
  <script type="text/javascript" src="./script/aui-slide.js"></script>
  <script type="text/javascript" src="./script/base.js"></script>
  <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
  <script type="text/javascript">
    function closeFrame(){
     api.setFrameGroupIndex({
      name: 'nav',
      index: 2,
      reload: true,
    });
     var setSele = 'changeSelect();';
     api.execScript({
      name: 'home',
      script: setSele,
    });
     api.closeFrame({
      name: 'sh_bank_withdraw'
    });
   };
 </script>
</head>
<body>
 <!-- 头部 -->
<!--  <header class="aui-bar aui-bar-nav" id="topbar">
    <a class="aui-pull-left aui-btn" onclick="closeFrame()">
        <span class="aui-iconfont aui-icon-left"></span>
    </a>
    <div class="aui-title">提现</div>
</header>
-->
<!--     <div class="sh-bank-t">
        <div class="sh-bank-t-t">
            <i class="CCB"></i>
            <h3>建设银行</h3>
            <p>
                快捷<span>支付</span>
            </p>
        </div>
        <div class="sh-bank-t-m">
            <ul class="aui-row">
                <li class="aui-col-xs-3">****</li>
                <li class="aui-col-xs-3">****</li>
                <li class="aui-col-xs-3">****</li>
                <li class="aui-col-xs-3">5623</li>
            </ul>
        </div>
        <div class="sh-bank-t-d">单笔限额5万元，单卡单日累计限额5万元</div>
      </div> -->
      <form id="withdrawForm" action="http://www.big-wealth.com/index.php?ctl=hrb&act=cash" method="post">
        <div class="sh-bank-d">
          <h3>可用余额(元) : <span id="money"></span></h3>
          <ul>
            <input type="hidden" name="agent" value="h5">
            <input type="hidden" name="userid" id="userid">
<!--               <li>
                <div class="aui-col-xs-4 text-l">可提现金额</div>
                <div class="aui-col-xs-8">156561.00元</div>
              </li> -->
              <li>
                <div class="aui-col-xs-3">提现金额</div>
                <div class="aui-col-xs-5"><input type="number" name="transAmt" onkeyup="limitMoney(this);" id="moneyNum" placeholder="请填写提现金额" maxlength="12" style="height:auto;">
                  <div class="check" id="checkWithdraw"></div>
                </div>
                <div class="aui-col-xs-4"></div>
              </li>
            </ul>
<!--         <div class="sh-bank-d-d">
            <label><input class="aui-radio" type="radio" name="demo1" checked=""> 普通提现</label>
            <label><input class="aui-radio" type="radio" name="demo1"> 即时提现</label>
        </div>
        <div class="aui-btn aui-btn-block aui-btn-sm">确认</div> -->
        <div class="aui-btn aui-btn-success aui-btn-block aui-btn-sm" onclick="withdraw()">确认</div>
        <p>您的充值资金将进入您的鄂托克前旗农商行存管账户</p>
      </div>
    </form>
  </body>
  <script type="text/javascript">
    apiready = function(){
      var user_id = $api.getStorage('userid');
      // 给用户id隐藏域赋值
      var userid = document.getElementById("userid");
      userid.value = user_id;
      // 可用余额
      var money = $api.getStorage('money');
      var moneyEle = document.getElementById("money");
      moneyEle.innerHTML = money;
    }

    $("#moneyNum").blur(function(){
      var moneyEle = $api.byId('moneyNum');
      var moneyNum = moneyEle.value;
  var money = toDecimal2(moneyNum);
      $("#moneyNum").val(money);
});


    function withdraw(){
      var moneyEle = $api.byId('moneyNum');
      var moneyNum = moneyEle.value;
    // 提现金额不能为空
    if (!moneyNum) {
      $api.byId('checkWithdraw').innerText = '提现金额不能为空';
      return false;
    }else{
      $api.byId('checkWithdraw').innerText = '';
    }

      // 提交表单
      var form = document.getElementById("withdrawForm");
      form.submit();
      api.toast({
        msg: '正在前往鄂托克农行存管系统...',
        duration: 2000,
        location: 'middle'
      });
    }

    // 限制金额只能输入小数后2位
    function limitMoney(obj){
        obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
      }
    </script>
    </html>
